﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using EvolutionBaseType;
using EvolutionBaseTypes;
using Evolution.Structure.Globe.Details;
using EvolutionBaseTypes.Interfaces;

namespace Evolution.Structure.Globe.Units
{
    public class BaseUnit : WorldItem, ILoadable<BaseUnit>, IMoveable, IBuildable
    {
        public Guid TypeId { get; set; }
        public string Name { get; set; }
        private bool moveableOnLand, moveableOnSea, moveableInAir;

        public UnitPoints AttackPoints { get; protected set; }
        public UnitPoints DefensePoints { get; protected set; }
        public int BuildingCosts { get;  set; }
        public double MaintenanceCosts { get; set; }
        public int MovePoints { get; set; }
        public int CargoSpace { get; set; }
        public UnitPoints AttackRange { get; set; }
        public int Health { get; set; }

        public List<Technology> Requiredtechnologies { get; set; }
        public List<Building> RequiredBuildings { get; set; }
        public List<Guid> CargoAbleUnits { get; set; }
        public List<Nation> AvailableForNation { get; set; }

        public Unit UpgradeableToUnit { get; set; } 


        public BaseUnit LoadData(LoaderFactory<BaseUnit> factory)
        {
            try
            {
                BaseUnit temp = factory.Load();
                this.TypeId = temp.TypeId;
                this.Name = temp.Name;
                this.AttackPoints = temp.AttackPoints;
                this.DefensePoints = temp.DefensePoints;
                this.BuildingCosts = temp.BuildingCosts;
                this.MaintenanceCosts = temp.MaintenanceCosts;
                this.MovePoints = temp.MovePoints;
                this.CargoSpace = temp.CargoSpace;
                this.AttackRange = temp.AttackRange;
                this.Health = temp.Health;
                this.Requiredtechnologies = temp.Requiredtechnologies;
                this.RequiredBuildings = temp.RequiredBuildings;
                this.CargoAbleUnits = temp.CargoAbleUnits;
                this.AvailableForNation = temp.AvailableForNation;
                this.UpgradeableToUnit = temp.UpgradeableToUnit;


                return this;
            }
            catch (Exception) { return null; }
        }


     
        public bool MoveableOnLand
        {
            get { return moveableOnLand; }
            set{ moveableOnLand = value;}
        }

        public bool MoveableOnSea
        {
            get { return moveableOnSea; }
            set { moveableOnSea = value; }
        }

        public bool MoveableInAir
        {
            get { return moveableInAir; }
            set { moveableInAir = value; }
        }
     
    }
}
